﻿using Base.Common;
using System;
using System.Collections.Generic;
using System.Net;
namespace Base.Common
{
    public abstract class ZtTaskConnect : ZtTask
    {
        public String ip;
        public int port;
        protected IPEndPoint ipEndPoint;
        public ZtTaskConnect() : base()
        {
            time = 3000;
        }
        protected override bool onlyOneTimeAsync()
        {

            return true;
        }
        protected String[] ports;
        public override void excute()
        {
            bool re = reConnect();
            if (re)
            {
                console(ip + ":" + port + "执行连接");
            }
        }
        protected abstract bool reConnect();
        protected override bool init()
        {
            base.init();
            IPAddress addr = IPAddress.Parse(ip);
            ipEndPoint = new IPEndPoint(addr, port);
            return true;
        }
    }
}
